/* eslint-disable react/no-array-index-key */
// 面试记录

import React from 'react';
import { Divider, List, Card } from 'antd';
import InterviewTag, { TYPES } from './InterviewTag';
import { DetailItem, Audio, CommentItem } from '../../components';

export default function EstimateDetail({
    interviewEvaluateResults,
    interviewArrangeResults,
    audioUrl,
    completeTimeJson,
    interviewStatus
}) {
    const result = interviewArrangeResults?.[0];
    const completeTimeArrange = JSON.parse(completeTimeJson || null) || {};
    if (!interviewEvaluateResults || !interviewEvaluateResults.length) {
        return null;
    }
    return (
        <Card>
            <DetailItem label="面谈总结" colon={false} style={{ fontWeight: 500 }}>
                <InterviewTag style={{ marginLeft: 12 }} type={TYPES.SUMMARY} status={interviewStatus} />
            </DetailItem>
            {result && (
                <>
                    <DetailItem label="结论"></DetailItem>
                    <CommentItem
                        style={{ margin: '12px 0 ' }}
                        avatar={result?.employeeAvatar}
                        name={result?.resultEmployeeName}
                        comment={result?.resultContent}
                    />
                </>
            )}
            {!!(audioUrl && completeTimeJson) && (
                <DetailItem label="面谈录音">
                    <Audio
                        url={audioUrl}
                        time={`${completeTimeArrange.startTime},${completeTimeArrange.endTime}`}
                    ></Audio>
                </DetailItem>
            )}
            <Divider style={{ margin: '12px 0 ' }} />
            <DetailItem label="面谈评估" />
            <List split={false}>
                {interviewEvaluateResults.map((item, index) => {
                    const { resultType, resultContent, resultEmployeeName, employeeAvatar } = item;
                    return (
                        <List.Item key={index}>
                            <CommentItem
                                avatar={employeeAvatar}
                                name={resultEmployeeName}
                                comment={resultContent}
                                tag={<InterviewTag status={resultType} />}
                            />
                        </List.Item>
                    );
                })}
            </List>
        </Card>
    );
}
